package com.leyou.search.MQlistener;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class Listener {

    @RabbitListener(bindings = @QueueBinding(//消费者   queue数组
            value = @Queue(value = "spring.test.queue", durable = "true"),//列队名字   持久
            exchange = @Exchange(
                    value = "spring.test.exchange",//路由名字
                    ignoreDeclarationExceptions = "true",//忽略申报错误
                    type = ExchangeTypes.TOPIC
            ),
            key = {"#.#"}))
    public void listen(String msg){
        System.out.println("接收到消息：" + msg);
    }
}
